﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NHibernateLinqExtensions.cs" company="Irdeto">
//   Copyright @ Irdeto 2012
// </copyright>
// <summary>
//   Class:NHibernateLinqExtensions
//   Namespace:AOTT.GateWay.DatabaseDao
//   Class Funtion:Represent the class providing some extending method about linq to NHibernate.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace BasicFrameworkDemo.DAL
{
    using System.Linq;
    using NHibernate;
    using NHibernate.Linq;

    /// <summary>
    /// Class:NHibernateLinqExtensions
    /// Namespace:AOTT.GateWay.DatabaseDao
    /// Class Funtion:Represent the class providing some extending method about linq to NHibernate.
    /// </summary>
    /// Creator:zhouchao
    /// Creation Date:11/14/2011 10:34 AM
    /// Modifier:
    /// Last Modified:
    /// ----------------------------------------------------------------------------------------
    public static class NHibernateLinqExtensions
    {
        /// <summary>
        /// Get the IQueryable{TEntity} by the ISession
        /// </summary>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <param name="session">The ISession</param>
        /// <returns>
        /// The IQueryable{TEntity}
        /// </returns>
        /// Creator:zhouchao
        /// Creation Date:11/4/2011 5:06 PM
        /// Modifier:
        /// Last Modified:
        /// ----------------------------------------------------------------------------------------
        public static IQueryable<TEntity> Linq<TEntity>(this ISession session)
        {
            return new NhQueryable<TEntity>(session.GetSessionImplementation());
        }

        /// <summary>
        /// Get the IQueryable{TEntity} by the IStatelessSession
        /// </summary>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <param name="session">The IStatelessSession</param>
        /// <returns>
        /// The IQueryable{TEntity}
        /// </returns>
        /// Creator:zhouchao
        /// Creation Date:11/4/2011 5:07 PM
        /// Modifier:
        /// Last Modified:
        /// ----------------------------------------------------------------------------------------
        public static IQueryable<TEntity> Linq<TEntity>(this IStatelessSession session)
        {
            return new NhQueryable<TEntity>(session.GetSessionImplementation());
        } 
    }
}
